package com.dididoctor.patient.Bean;

import android.content.Context;

import com.dididoctor.patient.Activity.GlobalParams;
import com.dididoctor.patient.Utils.SharedPreferencesUtils;


/**
 * @version 2.0
 * @类描述： Token
 * @项目名称：ddgh
 * @类名称： Token
 * @包名称： com.doudoukeji.service.Bean
 * @创建人：张强 boy
 * @创建时间：2016/3/14 15:54
 * @修改人：
 * @修改时间：2016/3/14 15:54
 * @修改备注： new parent class(用一句话描述修改了什么)
 */

public class Token {
    //    "userId": "10",
//            "phone": "15810046527",
//            "name": "158****6527",
//            "headPic": null,
//            "sex": null,
//            "birth": null,
//            "idNo": null,
//            "city": "",
//            "address": null,
//            "token": "8513757015E0C809D41166BBF845E868",
//            "accId": "10",
//            "accPwd": "8F1569336E9FAA9DAA30DD47034D85E8"
    private static String id;//用户
    private static String phone;//手机号
    private static String name;//用户名
    private static String headPic;//头像
    private static String sex;//性别
    private static String birth;//出生日期
    private static String idNo;//身份证号
    private static String city;//城市
    private static String address;//详细信息
    private static String token;//唯一识别码
    private static String disVersion;//24中小病版本号
    private static String accId;//网易登陆用户名
    private static String accPwd;//网易登陆密码
    private static String hasDoctor;//是否有签约医生


    private static String ID = "id";//用户
    private static String PHONE = "phone";//手机号
    private static String NAME = "name";//用户名
    private static String HEADPIC = "headPic";//头像
    private static String SEX = "sex";//性别
    private static String BIRTH = "birth";//出生日期
    private static String IDNO = "idNo";//身份证号
    private static String CITY = "city";//城市
    private static String ADDRESS = "address";//详细信息
    private static String TOKEN = "token";//唯一识别码
    private static String DISVERSION="disVersion";//24中小病版本号
    private static String ACCID="accId";//网易登陆用户名
    private static String ACCPWD="accPwd";//网易登陆密码
    private static String HASDOCTOR = "hasDoctor";//是否有签约医生


    public static Context mcontext;

    public static String getAccId() {
        if (!"".equals(accId) && accId != null) {
            return accId;
        } else {
            accId = SharedPreferencesUtils.getParam(mcontext, Token.ACCID, "");
            return accId;
        }
    }

    public static void setAccId(String accId) {
        Token.accId = accId;
        SharedPreferencesUtils.setParam(mcontext, Token.ACCID, accId);
    }

    public static String getAccPwd() {
        return accPwd;
    }

    public static void setAccPwd(String accPwd) {
        Token.accPwd = accPwd;
    }

    public static String getId() {
        if (!"".equals(id) && id != null) {
            return id;
        } else {
            id = SharedPreferencesUtils.getParam(mcontext, Token.ID, "");
            return id;
        }
    }

    public static void setId(String id) {
        Token.id = id;
        SharedPreferencesUtils.setParam(mcontext, Token.ID, id);
    }

    public static String getHasDoctor() {
        if (!"".equals(hasDoctor) && hasDoctor != null) {
            return hasDoctor;
        } else {
            hasDoctor = SharedPreferencesUtils.getParam(mcontext, Token.HASDOCTOR, "");
            return hasDoctor;
        }
    }

    public static void setHasDoctor(String hasDoctor) {
        Token.hasDoctor = hasDoctor;
        SharedPreferencesUtils.setParam(mcontext, Token.HASDOCTOR, hasDoctor);
    }

    public static String getDisVersion() {
        if (!"".equals(disVersion) && disVersion != null) {
            return disVersion;
        } else {
            disVersion = SharedPreferencesUtils.getParam(mcontext, Token.DISVERSION, "");
            return disVersion;
        }
    }

    public static void setDisVersion(String disVersion) {
        Token.disVersion = disVersion;
        SharedPreferencesUtils.setParam(mcontext, Token.DISVERSION, disVersion);
    }

    public static String getPhone() {
        if (!"".equals(phone) && phone != null) {
            return phone;
        } else {
            phone = SharedPreferencesUtils.getParam(mcontext, Token.PHONE, "");
            return phone;
        }
    }

    public static void setPhone(String phone) {
        Token.phone = phone;
        SharedPreferencesUtils.setParam(mcontext, Token.PHONE, phone);
    }

    public static String getName() {
        if (!"".equals(name) && name != null) {
            return name;
        } else {
            name = SharedPreferencesUtils.getParam(mcontext, Token.NAME, "");
            return name;
        }
    }

    public static void setName(String name) {
        Token.name = name;
        SharedPreferencesUtils.setParam(mcontext, Token.NAME, name);
    }

    public static String getHeadPic() {
        if (!"".equals(headPic) && headPic != null) {
            return headPic;
        } else {
            headPic = SharedPreferencesUtils.getParam(mcontext, Token.HEADPIC, "");
            return headPic;
        }
    }

    public static void setHeadPic(String headPic) {
        Token.headPic = headPic;
        SharedPreferencesUtils.setParam(mcontext, Token.HEADPIC, headPic);
    }

    public static String getSex() {
        if (!"".equals(sex) && sex != null) {
            return sex;
        } else {
            sex = SharedPreferencesUtils.getParam(mcontext, Token.SEX, "");
            return sex;
        }
    }

    public static void setSex(String sex) {
        Token.sex = sex;
        SharedPreferencesUtils.setParam(mcontext, Token.SEX, sex);
    }

    public static String getBirth() {
        if (!"".equals(birth) && birth != null) {
            return birth;
        } else {
            birth = SharedPreferencesUtils.getParam(mcontext, Token.BIRTH, "");
            return birth;
        }
    }

    public static void setBirth(String birth) {
        Token.birth = birth;
        SharedPreferencesUtils.setParam(mcontext, Token.BIRTH, birth);
    }

    public static String getIdNo() {
        if (!"".equals(idNo) && idNo != null) {
            return idNo;
        } else {
            idNo = SharedPreferencesUtils.getParam(mcontext, Token.IDNO, "");
            return idNo;
        }
    }

    public static void setIdNo(String idNo) {
        Token.idNo = idNo;
        SharedPreferencesUtils.setParam(mcontext, Token.IDNO, idNo);
    }

    public static String getCity() {
        if (!"".equals(city) && city != null) {
            return city;
        } else {
            city = SharedPreferencesUtils.getParam(mcontext, Token.CITY, "");
            return city;
        }
    }

    public static void setCity(String city) {
        Token.city = city;
        SharedPreferencesUtils.setParam(mcontext, Token.CITY, city);
    }

    public static String getAddress() {
        if (!"".equals(address) && address != null) {
            return address;
        } else {
            address = SharedPreferencesUtils.getParam(mcontext, Token.ADDRESS, "");
            return address;
        }
    }

    public static void setAddress(String address) {
        Token.address = address;
        SharedPreferencesUtils.setParam(mcontext, Token.ADDRESS, address);
    }

    public static String getToken() {
        if (!"".equals(token) && token != null) {
            return token;
        } else {
            token = SharedPreferencesUtils.getParam(mcontext, Token.TOKEN, "");
            return token;
        }
    }

    public static void setToken(String token) {
        Token.token = token;
        SharedPreferencesUtils.setParam(mcontext, Token.TOKEN, token);
    }


    public static Context getMcontext() {
        if (Token.mcontext != null) {
            return Token.mcontext;
        }
        return GlobalParams.getContext();
    }

    public static void setMcontext(Context mcontext) {
        if (Token.getMcontext() == null && mcontext != null) {
            Token.mcontext = mcontext;
        }
    }


    /**
     * 注销Token
     */
    public static void logout() {
        Token.id = "";
        Token.setId("");
        Token.phone = "";
        Token.setPhone("");
        Token.name = "";
        Token.setName("");
        Token.headPic = "";
        Token.setHeadPic("");
        Token.sex = "";
        Token.setSex("");
        Token.birth = "";
        Token.setBirth("");
        Token.idNo = "";
        Token.setId("");
        Token.city = "";
        Token.setCity("");
        Token.address = "";
        Token.setAddress("");
        Token.token = "";
        Token.setToken("");
    }


}
